package com.qfedu.buy.server.dao;

import com.qfedu.buy.common.dto.GoodsSkuDetailDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @program: NeighborBuy
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-02-04 09:42
 */
public interface GoodsSkuDao {
    @Select("select g.id gid,gs.id gskuid,gs.currprice gprice,gs.store,gs.sku gsku,o.ourl gpicurl,g.title gtile from t_goodssku gs inner join t_goods g on gs.gid=g.id inner join t_goodsmedia gm on gs.id=gm.gskuid and gm.type=6000 inner join t_ossstorage o on gm.osid=o.id where gs.id=#{skuid} and g.flag=4001")
    @ResultType(GoodsSkuDetailDto.class)
    GoodsSkuDetailDto selectById(int skuid);
    //扣减库存
    @Update("update t_goodssku set store=store+#{num} where id=#{id}")
    int update(@Param("id") int id,@Param("num") int num);
}